package cc.mrbird.febs.item.dao;

import cc.mrbird.febs.item.domain.ItemBean;
import cc.mrbird.febs.item.domain.UserItemBean;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ItemMapper extends BaseMapper<ItemBean> {
    @Select("select b.*, a.similar from " +
            "(select itemid2, similar from item_df where itemid1 = #{item.itemid}) a," +
            "item b where a.itemid2 = b.itemid order by a.similar desc")
    IPage<ItemBean> listItemById(Page page, @Param("item") ItemBean itemBean);

    @Select("select b.*, a.pref from " +
            "(select itemid, pref from user_cf where userid = #{item.userid}) a," +
            "item b where a.itemid = b.itemid order by a.pref desc")
    IPage<ItemBean> listItemByUser(Page page, @Param("item") UserItemBean userItemBean);

    @Select("select * from item")
    List<ItemBean> listItem();
}
